package com.cly.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cly.common.entity.order.dto.OrderDetailDto;
import com.cly.common.entity.item.po.Item;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ItemMapper extends BaseMapper<Item> {

    @Update("update item set stock = stock - #{num} where id = #{itemId}")
    void deductStock(OrderDetailDto orderDetailDto);

    @Update("update item set stock = stock + #{num} where id = #{itemId}")
    void recoverStock(OrderDetailDto orderDetailDto);
}
